<template>
  <div class="comparison">
    <div class="table">
      <el-table border
                style="width: 100%"
                :header-cell-style="{
          background: '#0070C0',
          color: '#ffffff',
        }"
                :data="tableData">
        <el-table-column label="环比下降客户TOP100(省政企)"
                         prop="city"
                         align="center">
          <el-table-column label="客户名"
                           prop="custName"
                           align="center"></el-table-column>
          <el-table-column label="环比下降(万元)"
                           prop="hb"
                           align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.hb < 0"
                    style="color:red;">{{scope.row.hb}}</span>
              <span v-else>{{scope.row.hb}}</span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>
      <el-table border
                style="width: 100%"
                :header-cell-style="{
          background: '#0070C0',
          color: '#ffffff',
        }"
                :data="tableData1">
        <el-table-column label="环比下降客户TOP100(市政企)"
                         prop="province"
                         align="center">
          <el-table-column label="客户名"
                           prop="custName"
                           align="center"></el-table-column>
          <el-table-column label="环比下降(万元)"
                           prop="hb"
                           align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.hb < 0"
                    style="color:red;">{{scope.row.hb}}</span>
              <span v-else>{{scope.row.hb}}</span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>
      <el-table border
                style="width: 100%"
                :header-cell-style="{
          background: '#0070C0',
          color: '#ffffff',
        }"
                :data="tableData2">
        <el-table-column label="环比下降客户TOP100(经营单元)"
                         prop="management"
                         align="center">
          <el-table-column label="客户名"
                           prop="custName"
                           align="center"></el-table-column>
          <el-table-column label="VIP归属"
                           prop="areaName"
                           align="center"></el-table-column>
          <el-table-column label="环比下降(万元)"
                           prop="hb"
                           align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.hb < 0"
                    style="color:red;">{{scope.row.hb}}</span>
              <span v-else>{{scope.row.hb}}</span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { customer } from "@/api/barCode/index";
export default {
  name: "comparison",
  components: {},
  props: {
    form: {
      type: Object,
      default: {},
    },
  },
  data () {
    return {
      tableData: [],
      tableData1: [],
      tableData2: []
    };
  },
  created () { },
  mounted () { },
  methods: {
    getList () {
      customer({
        acctMonth: this.form.acctMonth,
        type: '2'
      }).then((res) => {
        if (res.code == 200) {
          this.tableData = res.data.city;
          this.tableData1 = res.data.province;
          this.tableData2 = res.data.management;
        }
      });
    },
  },
};
</script>

<style scoped lang="scss">
.table {
  display: flex;
}
</style>
